<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
		<link rel="stylesheet" href="../layui/css/layui.css">
		<link href="../calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" type="text/css" href="../css/BillEdit.css">
		<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
		<script language="javascript">
			function doSave(contFlag) {
				document.getElementById("buttonDiv").style.display = "none";
				document.getElementById("waitDiv").style.display = "";
				document.getElementById("continue_flag").value = contFlag;

				ShowConfirm('确认框', '是否同时审核？', 340, 80, "doSaveCallBack()");

			}

			function doSaveCallBack() {
				if(popRetVal != null) {
					document.getElementById("examine").value = "1";
				}
				frm.submit();
			}

			function doCancel() {
				if(window.opener) {
					window.close();
				} else {
					parent.ClosePop();
				}
			}

			function elementOnChnage() {
				checkItemChange(this.getAttribute("index"), this.id);
			}

			function mtAddOnClick() {
				selectMakeType(this.getAttribute("index"));
			}

			function mtDelOnClick() {
				doClear("make_type_id_" + this.getAttribute("index"), "make_type_name_" + this.getAttribute("index"), this.getAttribute("index"));
			}

			function inputOnMouseOver() {
				this.title = this.value;
			}

			function proAddOnClick() {
				selectProduct(this.getAttribute("index"));
			}

			function proSeleStaOnClick() {
				doPriceSelectInde("STA", this.getAttribute("index"));
			}

			function proSeleEstOnClick() {
				doPriceSelectInde("EST", this.getAttribute("index"));
			}

			function requireButtonOnClick() {
				selectMakeRequire(this.getAttribute("index"));
			}

			function unitButtonOnClick() {
				selectUnit(this.getAttribute("index"));
			}

			function mrOnFocus() {
				this.style.height = "150px";
			}

			function mrOnBlur() {
				this.style.height = "34px";
			}

			function mrTaOnFocus(obj) {
				obj.style.height = "150px";
			}

			function mrTaOnBlur(obj) {
				obj.style.height = "34px";
			}

			function bbCodeAddOnClick() {
				var priceType = document.getElementById("price_type_" + this.getAttribute("index")).value;
				doBbItemLink(priceType, this.getAttribute("index"));
			}

			function bbCodeDelOnClick() {
				doClear("bb_item_id_" + this.getAttribute("index"), "bb_code_" + this.getAttribute("index"), this.getAttribute("index"));
			}

			function doLengTypeChange(index) {
				if(document.getElementsByName("lt_" + index)[0].checked) {
					document.getElementById("leng_type_" + index).value = "M";
				} else {
					if(document.getElementById("price_type_" + index).value == "AREA") {
						document.getElementById("leng_type_" + index).value = "MM";
					} else {
						document.getElementById("leng_type_" + index).value = "CM";
					}
				}
				checkItemChange(index, "length_" + index);
			}

			function ltOnChange() {
				doLengTypeChange(this.getAttribute("index"));
			}

			function doProNameChange(index) {
				document.getElementById("pro_id_" + index).value = "0";
				document.getElementById("proFlagSpan_" + index).style.display = "none";
				checkItemChange(index);
			}

			function pnOnChange() {
				doProNameChange(this.getAttribute("index"));
			}

			function selectProduct(index) {
				var url = "/base/ProductMainForSelect.ihtm";
				ShowIframe("选择材料", url, 900, 500, "selectProductCallBack(" + index + ")");
			}

			function selectProductCallBack(index) {
				if(popRetVal != null) {
					var estId = document.getElementById("cooperBill.cooperatorId").value;
					var mtId = document.getElementById("make_type_id_" + index).value;
					var proId = popRetVal[0];
					var proName = popRetVal[2];
					var proUnit = popRetVal[3];

					document.getElementById("LoadProcess").style.top = getTopPos(document.getElementById("pro_name_" + index)) + 50 + "px";
					document.getElementById("LoadProcess").style.left = getleftPos(document.getElementById("pro_name_" + index)) + 100 + "px";
					$("#LoadProcess").show();
					$.post("/base/GetEstPric.ihtm", {
						est_type: "COOPERATOR",
						price_type: "EST",
						est_id: estId,
						mt_id: mtId,
						pro_name: proName,
						get_sta: "Y"
					}, function(data, status) {
						parsePriceData(data, status, proId, proName, proUnit, index);
					});

				}
			}

			function parsePriceData(data, status, proId, proName, proUnit, index) {
				if(status == "success") {
					var obj = $.parseJSON(data);
					if(obj.status == "ERROR") {
						$("#LoadProcess").hide();
						ShowAlert('提示框', obj.errMsg, 200, 100);
					} else {
						$("#pro_id_" + index).val(proId);
						$("#pro_name_" + index).val(proName);
						if($("#price_type_" + index).val() == "AMOUNT") {
							$("#unit_" + index).val(proUnit);
						}
						$("#unit_price_" + index).val(obj.pric);

						document.getElementById("proFlagSpan_" + index).style.display = "";
						checkItemChange(index);

						$("#LoadProcess").hide();
					}
				} else {
					$("#LoadProcess").hide();
					ShowAlert('提示框', '系统错误：' + status, 200, 100);
				}
			}

			function selectMakeRequire(index) {
				var url = "/base/MakeRequireListForSelect.ihtm";
				ShowIframe("选择制作要求", url, 900, 500, "selectMakeRequireCallBack(" + index + ")");
			}

			function selectMakeRequireCallBack(index) {
				if(popRetVal != null) {
					var theValue = document.getElementById("make_require_" + index).value;
					for(i = 0; i < popRetVal.length; i++) {
						if(theValue != null && theValue != "") {
							theValue = theValue + "\n";
						}
						theValue = theValue + popRetVal[i][0];
					}
					document.getElementById("make_require_" + index).value = theValue;
					checkItemChange(index);
				}
			}

			function selectUnit(index) {
				var url = "/base/UnitListForSelect.ihtm";
				ShowIframe("选择单位", url, 300, 400, "selectUnitCallBack(" + index + ")");
			}

			function selectUnitCallBack(index) {
				if(popRetVal != null) {
					document.getElementById("unit_" + index).value = popRetVal[1];
					checkItemChange(index);
				}
			}

			function selectMakeType(index) {
				var url = "/base/MakeTypeListForSelect.ihtm";
				ShowIframe("选择项目类型", url, 310, 500, "selectMakeTypeCallBack(" + index + ")");
			}

			function selectMakeTypeCallBack(index) {
				if(popRetVal != null) {
					document.getElementById("make_type_id_" + index).value = popRetVal[0];
					document.getElementById("make_type_name_" + index).value = popRetVal[1];
					if(document.getElementById("unit_" + index) != null) {
						document.getElementById("unit_" + index).value = popRetVal[4];
					}
					checkItemChange(index);
				}
			}

			function doBbItemSelect(priceType, linkObjId) {
				var url = "/cooper/BbItemListForCooperSelect.ihtm?type=MULTI&just_cooper=Y&price_type=" + priceType + "&ts_id=2";
				ShowIframe("选择业务单项目", url, 1024, 500, "doBbItemSelectCallBack('" + priceType + "','" + linkObjId + "')");
			}

			function doBbItemSelectCallBack(priceType, linkObjId) {
				if(popRetVal != null && popRetVal.length > 0) {
					document.getElementById("LoadProcess").style.top = getTopPos(document.getElementById(linkObjId)) + 50 + "px";
					document.getElementById("LoadProcess").style.left = getleftPos(document.getElementById(linkObjId)) + 100 + "px";
					$("#LoadProcess").show();

					var estId = document.getElementById("cooperBill.cooperatorId").value;
					var lastItem = false;
					for(i = 0; i < popRetVal.length; i++) {
						var mtId = popRetVal[i][0];
						var proName = popRetVal[i][3];
						if(i == popRetVal.length - 1) {
							lastItem = true;
						}

						/**这里是在for循环里面,不能使用异步形式的$.post,否则会有问题(parseBbPriceData引用的变量会被改变)
		    	$.post("/base/GetEstPric.ihtm",{est_type:"COOPERATOR",price_type:"EST",est_id:estId,mt_id:mtId,pro_name:proName,get_sta:"Y"},function(data,status){
					//alert(i);
					parseBbPriceData(data,status,priceType,popRetVal[i],lastItem);
				});
		    	**/
						$.ajax({
							url: "/base/GetEstPric.ihtm",
							type: "POST",
							data: {
								est_type: "COOPERATOR",
								price_type: "EST",
								est_id: estId,
								mt_id: mtId,
								pro_name: proName,
								get_sta: "Y"
							},
							async: false, //同步
							error: function(xhr) {
								$("#LoadProcess").hide();
								ShowAlert('提示框', xhr.status + " " + xhr.statusText, 200, 100);
							},
							success: function(data, status) {
								parseBbPriceData(data, status, priceType, popRetVal[i], lastItem);
							}
						});
					}
				}
			}

			function parseBbPriceData(data, status, priceType, defVals, lastItem) {
				if(status == "success") {
					var obj = $.parseJSON(data);
					if(obj.status == "ERROR") {
						$("#LoadProcess").hide();
						ShowAlert('提示框', obj.errMsg, 200, 100);
					} else {
						defVals[11] == obj.pric;

						if(priceType == "AREA") {
							doAreaItemAdd(defVals);
						} else if(priceType == "AMOUNT") {
							doAmountItemAdd(defVals);
						} else if(priceType == "LENGTH") {
							doLengthItemAdd(defVals);
						}

						if(lastItem) {
							$("#LoadProcess").hide();
						}
					}
				} else {
					$("#LoadProcess").hide();
					ShowAlert('提示框', '系统错误：' + status, 200, 100);
				}
			}

			function doBbItemLink(priceType, index) {
				var url = "/cooper/BbItemListForCooperSelect.ihtm?ts_id=2"; //单选的不要priceType
				ShowIframe("选择业务单项目", url, 1024, 500, "doBbItemLinkCallBack('" + priceType + "'," + index + ")");
			}

			function doBbItemLinkCallBack(priceType, index) {
				if(popRetVal != null) {
					document.getElementById("bb_item_id_" + index).value = popRetVal[14];
					document.getElementById("bb_code_" + index).value = popRetVal[15];
					if(document.getElementById("id_" + index).value == "" || document.getElementById("id_" + index).value == "0") {
						document.getElementById("status_" + index).value = "NEW";
					} else {
						document.getElementById("status_" + index).value = "EDIT";
					}
				}
			}

			function doItemSelect(priceType) {
				var cooperatorId = document.getElementById("cooperBill.cooperatorId").value;
				var url = "/cooper/CooperBillItemListForSelect.ihtm?id=" + cooperatorId + "&price_type=" + priceType + "&ts_id=2";
				ShowIframe("选择历史价格", url, 1024, 500, "doItemSelectCallBack('" + priceType + "')");
			}

			function doItemSelectCallBack(priceType) {
				if(popRetVal != null) {
					for(i = 0; i < popRetVal.length; i++) {
						if(priceType == "AREA") {
							doAreaItemAdd(popRetVal[i]);
						} else if(priceType == "AMOUNT") {
							doAmountItemAdd(popRetVal[i]);
						} else if(priceType == "LENGTH") {
							doLengthItemAdd(popRetVal[i]);
						}
					}
				}
			}

			function doCbItemSelect(itemPriceType, estPriceType) {
				var cooperatorId = document.getElementById("cooperBill.cooperatorId").value;
				var url = "/base/EstPriceListForSelect.ihtm?type=MULTI&est_type=COOPERATOR&price_type=" + estPriceType;
				var titl = "选择标准价格";
				if(estPriceType == 'EST') {
					if(cooperatorId == null || cooperatorId == "" || cooperatorId == "0") {
						ShowAlert('提示框', '请先选择外协商！', 200, 100);
						return;
					}
					url = url + "&est_id=" + cooperatorId;
					titl = "选择外协商价格";
				}
				ShowIframe(titl, url, 900, 500, "doCbItemSelectCallBack('" + itemPriceType + "')");
			}

			function doCbItemSelectCallBack(itemPriceType) {
				if(popRetVal != null) {
					for(i = 0; i < popRetVal.length; i++) {
						var arr = new Array();
						arr[0] = popRetVal[i][0];
						arr[1] = popRetVal[i][1];
						arr[2] = popRetVal[i][2];
						arr[3] = popRetVal[i][3];
						if(popRetVal[i][9] == "") {
							arr[4] = "0";
						} else {
							arr[4] = popRetVal[i][9];
						}
						if(popRetVal[i][10] == "") {
							arr[5] = "0";
						} else {
							arr[5] = popRetVal[i][10];
						}
						arr[6] = popRetVal[i][11];
						arr[7] = "";
						arr[8] = popRetVal[i][4];
						arr[9] = popRetVal[i][5];
						arr[10] = "0";
						arr[11] = popRetVal[i][6];
						arr[12] = "0";
						arr[13] = "0";
						arr[14] = "0";
						arr[15] = "";
						if(itemPriceType == "AREA") {
							arr[16] = "M"; //leng type
							doAreaItemAdd(arr);
						} else if(itemPriceType == "AMOUNT") {
							arr[16] = "";
							doAmountItemAdd(arr);
						} else if(itemPriceType == "LENGTH") {
							arr[16] = "M"; //leng type
							doLengthItemAdd(arr);
						}
					}
				}
			}

			function doPriceSelectInde(estPriceType, index) {
				var cooperatorId = document.getElementById("cooperBill.cooperatorId").value;
				var mtId = document.getElementById("make_type_id_" + index).value;
				var url = "/base/EstPriceListForSelect.ihtm?est_type=COOPERATOR&price_type=" + estPriceType + "&mt_id=" + mtId;
				var titl = "选择标准价格";
				if(estPriceType == 'EST') {
					url = url + "&est_id=" + cooperatorId;
					titl = "选择外协商价格";
				}
				ShowIframe(titl, url, 900, 500, "doPriceSelectIndeCallBack('" + index + "')");
			}

			function doPriceSelectIndeCallBack(index) {
				if(popRetVal != null) {
					//document.getElementById("make_type_id_"+index).value=popRetVal[0];
					//document.getElementById("make_type_name_"+index).value=popRetVal[1];
					document.getElementById("pro_id_" + index).value = popRetVal[2];
					document.getElementById("pro_name_" + index).value = popRetVal[3];
					//document.getElementById("specification_"+index).value=popRetVal[11];
					//document.getElementById("make_require_"+index).value=popRetVal[4];
					document.getElementById("unit_price_" + index).value = popRetVal[6];
					/**
					if(document.getElementById("length_"+index)){
						if(popRetVal[9]==""){
							document.getElementById("length_"+index).value="0";
						}else{
							document.getElementById("length_"+index).value=popRetVal[9];
						}
						if(popRetVal[10]==""){
							document.getElementById("width_"+index).value="0";
						}else{
							document.getElementById("width_"+index).value=popRetVal[10];
						}
					}
					if(document.getElementById("unit_"+index)){
						document.getElementById("unit_"+index).value=popRetVal[5];
					}
					**/
					if(document.getElementById("pro_id_" + index).value == "0") {
						document.getElementById("proFlagSpan_" + index).style.display = "none";
					} else {
						document.getElementById("proFlagSpan_" + index).style.display = "";
					}
					checkItemChange(index);
				}
			}

			function doAreaItemAdd(defVals) {
				var entAreaType = "M";
				var tbl = document.getElementById("areaItemRowTbl");
				var itemNum = document.getElementById("item_num").value - 0;

				var tr = document.createElement("tr");
				tr.setAttribute("className", "ListTr");
				tr.setAttribute("class", "ListTr");
				tr.setAttribute("id", "itemTr" + itemNum);

				var td;
				var input;

				createItemPublicStartPart(tr, itemNum, defVals);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "40px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "length_" + itemNum);
				input.setAttribute("id", "length_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[4]);
				} else {
					input.setAttribute("value", "0");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				td.appendChild(document.createTextNode(" x "));
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "40px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "width_" + itemNum);
				input.setAttribute("id", "width_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[5]);
				} else {
					input.setAttribute("value", "0");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);

				td.appendChild(document.createElement("br"));
				input = document.createElement("input");
				input.setAttribute("type", "radio");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "lt_" + itemNum);
				input.onclick = ltOnChange; //radio在onchange时,在ie取得是change前的值,所以这里不能用onchange
				if(defVals != null) {
					if(defVals[16] == "M") {
						input.setAttribute("checked", true);
					}
				} else {
					if(entAreaType == "M") {
						input.setAttribute("checked", true);
					}
				}
				td.appendChild(input);
				td.appendChild(document.createTextNode("m"));
				input = document.createElement("input");
				input.setAttribute("type", "radio");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "lt_" + itemNum);
				input.onclick = ltOnChange;
				if(defVals != null) {
					if(defVals[16] == "MM") {
						input.setAttribute("checked", true);
					}
				} else {
					if(entAreaType == "MM") {
						input.setAttribute("checked", true);
					}
				}
				td.appendChild(input);
				td.appendChild(document.createTextNode("mm"));
				input = document.createElement("input");
				input.setAttribute("type", "hidden");
				input.setAttribute("name", "leng_type_" + itemNum);
				input.setAttribute("id", "leng_type_" + itemNum);
				if(defVals != null) {
					input.setAttribute("value", defVals[16]);
				} else {
					input.setAttribute("value", entAreaType);
				}
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input = document.createElement("textarea");
				input.style.width = "66px";
				input.style.height = "34px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "specification_" + itemNum);
				input.setAttribute("id", "specification_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.value = defVals[6];
					//input.setAttribute("value",defVals[6]);//textarea时safari不支持
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("textarea");
				input.style.width = "90px";
				input.style.height = "34px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "make_require_" + itemNum);
				input.setAttribute("id", "make_require_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				input.onfocus = mrOnFocus;
				input.onblur = mrOnBlur;
				if(defVals != null) {
					input.value = defVals[8];
					//input.setAttribute("value",defVals[8]);//textarea时safari不支持
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));
				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_add.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = requireButtonOnClick;
				td.appendChild(input);

				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "44px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "amount_" + itemNum);
				input.setAttribute("id", "amount_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[10]);
				} else {
					input.setAttribute("value", "0");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "50px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "square_num_" + itemNum);
				input.setAttribute("id", "square_num_" + itemNum);
				input.setAttribute("className", "TextBox readonly");
				input.setAttribute("class", "TextBox readonly");
				if(defVals != null) {
					input.setAttribute("value", defVals[12]);
				} else {
					input.setAttribute("value", "0");
				}
				input.setAttribute("readOnly", true);
				td.appendChild(input);
				tr.appendChild(td);

				createItemPublicEndPart(tbl, tr, itemNum, defVals, "AREA");
			}

			function doAmountItemAdd(defVals) {
				var tbl = document.getElementById("amountItemRowTbl");
				var itemNum = document.getElementById("item_num").value - 0;

				var tr = document.createElement("tr");
				tr.setAttribute("className", "ListTr");
				tr.setAttribute("class", "ListTr");
				tr.setAttribute("id", "itemTr" + itemNum);

				var td;
				var input;

				createItemPublicStartPart(tr, itemNum, defVals);

				td = document.createElement("td");
				input = document.createElement("input");
				input = document.createElement("textarea");
				input.style.width = "100px";
				input.style.height = "34px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "specification_" + itemNum);
				input.setAttribute("id", "specification_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.value = defVals[6];
					//input.setAttribute("value",defVals[6]);//textarea时safari不支持
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("textarea");
				input.style.width = "140px";
				input.style.height = "34px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "make_require_" + itemNum);
				input.setAttribute("id", "make_require_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				input.onfocus = mrOnFocus;
				input.onblur = mrOnBlur;
				if(defVals != null) {
					input.value = defVals[8];
					//input.setAttribute("value",defVals[8]);//textarea时safari不支持
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));
				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_add.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = requireButtonOnClick;
				td.appendChild(input);

				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "50px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "unit_" + itemNum);
				input.setAttribute("id", "unit_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[9]);
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));
				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_add.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = unitButtonOnClick;
				td.appendChild(input);

				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "50px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "amount_" + itemNum);
				input.setAttribute("id", "amount_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[10]);
				} else {
					input.setAttribute("value", "0");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				createItemPublicEndPart(tbl, tr, itemNum, defVals, "AMOUNT");
			}

			function doLengthItemAdd(defVals) {
				var entLengType = "M";
				var tbl = document.getElementById("lengthItemRowTbl");
				var itemNum = document.getElementById("item_num").value - 0;

				var tr = document.createElement("tr");
				tr.setAttribute("className", "ListTr");
				tr.setAttribute("class", "ListTr");
				tr.setAttribute("id", "itemTr" + itemNum);

				var td;
				var input;

				createItemPublicStartPart(tr, itemNum, defVals);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "40px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "length_" + itemNum);
				input.setAttribute("id", "length_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[4]);
				} else {
					input.setAttribute("value", "0");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				td.appendChild(document.createTextNode(" x "));
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "40px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "width_" + itemNum);
				input.setAttribute("id", "width_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[5]);
				} else {
					input.setAttribute("value", "0");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input = document.createElement("textarea");
				input.style.width = "66px";
				input.style.height = "34px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "specification_" + itemNum);
				input.setAttribute("id", "specification_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.value = defVals[6];
					//input.setAttribute("value",defVals[6]);//textarea时safari不支持
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("textarea");
				input.style.width = "90px";
				input.style.height = "34px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "make_require_" + itemNum);
				input.setAttribute("id", "make_require_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				input.onfocus = mrOnFocus;
				input.onblur = mrOnBlur;
				if(defVals != null) {
					input.value = defVals[8];
					//input.setAttribute("value",defVals[8]);//textarea时safari不支持
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));
				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_add.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = requireButtonOnClick;
				td.appendChild(input);

				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "44px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "amount_" + itemNum);
				input.setAttribute("id", "amount_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[10]);
				} else {
					input.setAttribute("value", "0");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "50px";
				input.setAttribute("maxLength", "10");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "square_num_" + itemNum);
				input.setAttribute("id", "square_num_" + itemNum);
				input.setAttribute("className", "TextBox readonly");
				input.setAttribute("class", "TextBox readonly");
				if(defVals != null) {
					input.setAttribute("value", defVals[12]);
				} else {
					input.setAttribute("value", "0");
				}
				input.setAttribute("readOnly", true);
				td.appendChild(input);

				td.appendChild(document.createElement("br"));
				input = document.createElement("input");
				input.setAttribute("type", "radio");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "lt_" + itemNum);
				input.onclick = ltOnChange; //radio在onchange时,在ie取得是change前的值,所以这里不能用onchange
				if(defVals != null) {
					if(defVals[16] == "M") {
						input.setAttribute("checked", true);
					}
				} else {
					if(entLengType == "M") {
						input.setAttribute("checked", true);
					}
				}
				td.appendChild(input);
				td.appendChild(document.createTextNode("m"));
				input = document.createElement("input");
				input.setAttribute("type", "radio");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "lt_" + itemNum);
				input.onclick = ltOnChange;
				if(defVals != null) {
					if(defVals[16] == "CM") {
						input.setAttribute("checked", true);
					}
				} else {
					if(entLengType == "CM") {
						input.setAttribute("checked", true);
					}
				}
				td.appendChild(input);
				td.appendChild(document.createTextNode("cm"));
				input = document.createElement("input");
				input.setAttribute("type", "hidden");
				input.setAttribute("name", "leng_type_" + itemNum);
				input.setAttribute("id", "leng_type_" + itemNum);
				if(defVals != null) {
					input.setAttribute("value", defVals[16]);
				} else {
					input.setAttribute("value", entLengType);
				}
				td.appendChild(input);
				tr.appendChild(td);

				createItemPublicEndPart(tbl, tr, itemNum, defVals, "LENGTH");
			}

			function createItemPublicStartPart(tr, itemNum, defVals) {
				var td;
				var input;
				var busiProd = "SELECT";

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "80px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "make_type_name_" + itemNum);
				input.setAttribute("id", "make_type_name_" + itemNum);
				input.onmouseover = inputOnMouseOver;
				input.setAttribute("className", "TextBox readonly");
				input.setAttribute("class", "TextBox readonly");
				if(defVals != null) {
					input.setAttribute("value", defVals[1]);
				} else {
					input.setAttribute("value", "");
				}
				input.setAttribute("readOnly", true);
				td.appendChild(input);

				td.appendChild(document.createElement("br"));

				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_add.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = mtAddOnClick;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));

				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_del.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = mtDelOnClick;
				td.appendChild(input);

				input = document.createElement("input");
				input.setAttribute("type", "hidden");
				input.setAttribute("name", "make_type_id_" + itemNum);
				input.setAttribute("id", "make_type_id_" + itemNum);
				if(defVals != null) {
					input.setAttribute("value", defVals[0]);
				} else {
					input.setAttribute("value", "0");
				}
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("textarea");
				input.style.width = "206px";
				input.style.height = "34px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "finished_content_" + itemNum);
				input.setAttribute("id", "finished_content_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.value = defVals[7];
					//input.setAttribute("value",defVals[7]);//textarea时safari不支持
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "80px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "pro_name_" + itemNum);
				input.setAttribute("id", "pro_name_" + itemNum);
				input.onmouseover = inputOnMouseOver;
				if(busiProd == "SELECT") {
					input.setAttribute("className", "TextBox readonly");
					input.setAttribute("class", "TextBox readonly");
					input.setAttribute("readOnly", true);
				} else {
					input.setAttribute("className", "TextBox");
					input.setAttribute("class", "TextBox");
				}
				if(defVals != null) {
					input.setAttribute("value", defVals[3]);
				} else {
					input.setAttribute("value", "");
				}
				input.onchange = pnOnChange;
				td.appendChild(input);

				td.appendChild(document.createElement("br"));
				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_add.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = proAddOnClick;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));
				input = document.createElement("img");
				input.setAttribute("src", "/images/a27.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.setAttribute("title", "选择标准价格");
				input.onclick = proSeleStaOnClick;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));
				input = document.createElement("img");
				input.setAttribute("src", "/images/ico-bar.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.setAttribute("title", "选择外协商价格");
				input.onclick = proSeleEstOnClick;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));
				input = document.createElement("span");
				input.setAttribute("id", "proFlagSpan_" + itemNum);
				input.setAttribute("className", "MustInput");
				input.setAttribute("class", "MustInput");
				input.appendChild(document.createTextNode("*"));
				if(defVals == null || defVals[2] == "0") {
					input.style.display = "none";
				}
				td.appendChild(input);

				input = document.createElement("input");
				input.setAttribute("type", "hidden");
				input.setAttribute("name", "pro_id_" + itemNum);
				input.setAttribute("id", "pro_id_" + itemNum);
				if(defVals != null) {
					input.setAttribute("value", defVals[2]);
				} else {
					input.setAttribute("value", "0");
				}
				td.appendChild(input);
				tr.appendChild(td);
			}

			function createItemPublicEndPart(tbl, tr, itemNum, defVals, priceType) {
				var td;
				var input;

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "44px";
				input.setAttribute("maxLength", "19");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "unit_price_" + itemNum);
				input.setAttribute("id", "unit_price_" + itemNum);
				input.setAttribute("className", "TextBox");
				input.setAttribute("class", "TextBox");
				if(defVals != null) {
					input.setAttribute("value", defVals[11]);
				} else {
					input.setAttribute("value", "0");
				}
				input.onchange = elementOnChnage;
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "44px";
				input.setAttribute("maxLength", "19");
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "cost_" + itemNum);
				input.setAttribute("id", "cost_" + itemNum);
				input.setAttribute("className", "TextBox readonly");
				input.setAttribute("class", "TextBox readonly");
				if(defVals != null) {
					input.setAttribute("value", defVals[13]);
				} else {
					input.setAttribute("value", "0");
				}
				input.setAttribute("readOnly", true);
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				input = document.createElement("input");
				input.setAttribute("type", "text");
				input.style.width = "114px";
				input.setAttribute("index", itemNum);
				input.setAttribute("name", "bb_code_" + itemNum);
				input.setAttribute("id", "bb_code_" + itemNum);
				input.onmouseover = inputOnMouseOver;
				input.setAttribute("className", "TextBox readonly");
				input.setAttribute("class", "TextBox readonly");
				if(defVals != null) {
					input.setAttribute("value", defVals[15]);
				} else {
					input.setAttribute("value", "");
				}
				input.setAttribute("readOnly", true);
				td.appendChild(input);

				td.appendChild(document.createElement("br"));

				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_add.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = bbCodeAddOnClick;
				td.appendChild(input);

				td.appendChild(document.createTextNode(" "));

				input = document.createElement("img");
				input.setAttribute("src", "/images/icon_del.gif");
				input.setAttribute("index", itemNum);
				input.style.cursor = "pointer";
				input.onclick = bbCodeDelOnClick;
				td.appendChild(input);

				input = document.createElement("input");
				input.setAttribute("type", "hidden");
				input.setAttribute("name", "bb_item_id_" + itemNum);
				input.setAttribute("id", "bb_item_id_" + itemNum);
				if(defVals != null) {
					input.setAttribute("value", defVals[14]);
				} else {
					input.setAttribute("value", "0");
				}
				td.appendChild(input);
				tr.appendChild(td);

				td = document.createElement("td");
				var delLink = document.createElement("a");
				delLink.setAttribute("href", "javascript:doItemDelete(" + itemNum + ");");
				delLink.appendChild(document.createTextNode("删除"));
				td.appendChild(delLink);
				td.appendChild(document.createElement("br"));
				var copyLink = document.createElement("a");
				copyLink.setAttribute("href", "javascript:doItemCopy(" + itemNum + ",'" + priceType + "');");
				copyLink.appendChild(document.createTextNode("复制"));
				td.appendChild(copyLink);

				input = document.createElement("input");
				input.setAttribute("type", "hidden");
				input.setAttribute("name", "status_" + itemNum);
				input.setAttribute("id", "status_" + itemNum);
				if(defVals != null) {
					input.setAttribute("value", "NEW");
				} else {
					input.setAttribute("value", "UNCHANGE");
				}
				td.appendChild(input);
				input = document.createElement("input");
				input.setAttribute("type", "hidden");
				input.setAttribute("name", "price_type_" + itemNum);
				input.setAttribute("id", "price_type_" + itemNum);
				input.setAttribute("value", priceType);
				td.appendChild(input);
				input = document.createElement("input");
				input.setAttribute("type", "hidden");
				input.setAttribute("name", "id_" + itemNum);
				input.setAttribute("id", "id_" + itemNum);
				input.setAttribute("value", "0");
				td.appendChild(input);

				tr.appendChild(td);

				tbl.appendChild(tr);
				document.getElementById("item_num").value = itemNum + 1;

				if(defVals != null) {
					//doCount();
					checkItemChange(itemNum);
				} else {
					selectMakeType(itemNum); //空白的才弹出
				}

				resizePopwin();
			}

			function doItemDelete(index) {
				ShowConfirm('确认框', '确定删除吗？', 340, 80, "doItemDeleteCallBack(" + index + ")");
			}

			function doItemDeleteCallBack(index) {
				if(popRetVal != null) {
					document.getElementById("itemTr" + index).style.display = "none";
					document.getElementById("status_" + index).value = "DELETE";
					doCount();

					resizePopwin();
				}
			}

			function doItemCopy(index, priceType) {
				var defVals = new Array();
				defVals[0] = document.getElementById("make_type_id_" + index).value;
				defVals[1] = document.getElementById("make_type_name_" + index).value;
				defVals[2] = document.getElementById("pro_id_" + index).value;
				defVals[3] = document.getElementById("pro_name_" + index).value;
				defVals[6] = document.getElementById("specification_" + index).value;
				defVals[7] = document.getElementById("finished_content_" + index).value;
				defVals[8] = document.getElementById("make_require_" + index).value;
				defVals[10] = document.getElementById("amount_" + index).value;
				defVals[11] = document.getElementById("unit_price_" + index).value;
				defVals[13] = document.getElementById("cost_" + index).value;
				defVals[14] = document.getElementById("bb_item_id_" + index).value;
				defVals[15] = document.getElementById("bb_code_" + index).value;
				if(priceType == "AREA") {
					defVals[4] = document.getElementById("length_" + index).value;
					defVals[5] = document.getElementById("width_" + index).value;
					defVals[9] = "";
					defVals[12] = document.getElementById("square_num_" + index).value;
					defVals[16] = document.getElementById("leng_type_" + index).value
					doAreaItemAdd(defVals);
				} else if(priceType == "AMOUNT") {
					defVals[4] = "0";
					defVals[5] = "0";
					defVals[9] = document.getElementById("unit_" + index).value;
					defVals[12] = "0";
					defVals[16] = "";
					doAmountItemAdd(defVals);
				} else if(priceType == "LENGTH") {
					defVals[4] = document.getElementById("length_" + index).value;
					defVals[5] = document.getElementById("width_" + index).value;
					defVals[9] = "";
					defVals[12] = document.getElementById("square_num_" + index).value;
					defVals[16] = document.getElementById("leng_type_" + index).value
					doLengthItemAdd(defVals);
				}
			}

			function checkItemChange(index, id) {
				if(document.getElementById("id_" + index).value == "" || document.getElementById("id_" + index).value == "0") {
					document.getElementById("status_" + index).value = "NEW";
				} else {
					document.getElementById("status_" + index).value = "EDIT";
				}

				var priceType = document.getElementById("price_type_" + index).value;
				var itemAmount = document.getElementById("amount_" + index).value;
				var itemUnitPrice = document.getElementById("unit_price_" + index).value;
				var itemCost = document.getElementById("cost_" + index).value;
				if(priceType == "AREA") {
					var itemLength = document.getElementById("length_" + index).value;
					var itemWidth = document.getElementById("width_" + index).value;
					var itemSquareNum = document.getElementById("square_num_" + index).value;
					//平方数
					if(!isNaN(itemLength) && !isNaN(itemWidth) && !isNaN(itemAmount)) {
						itemSquareNum = accMul(accMul(itemLength, itemWidth), itemAmount);
						if(document.getElementById("leng_type_" + index).value == "MM") {
							itemSquareNum = itemSquareNum / 1000000;
						}
						itemSquareNum = parseScale(itemSquareNum, 3);
						document.getElementById("square_num_" + index).value = itemSquareNum;
					}
					//规格
					if(id == "length_" + index || id == "width_" + index) {
						if(!isNaN(itemLength) && !isNaN(itemWidth)) {
							var lt = document.getElementById("leng_type_" + index).value.toLowerCase();;
							var speStr = "";
							if(itemLength - 0 != 0) {
								speStr = itemLength + lt;
							}
							if(itemWidth - 0 != 0) {
								if(speStr != "") {
									speStr = speStr + " x ";
								}
								speStr = speStr + itemWidth + lt;
							}
							document.getElementById("specification_" + index).value = speStr + "高";
						}
					}
					//金额
					if(!isNaN(itemSquareNum) && !isNaN(itemUnitPrice)) {
						itemCost = accMul(itemSquareNum, itemUnitPrice);
						document.getElementById("cost_" + index).value = parseScale(itemCost, 2);
					}
				} else if(priceType == "AMOUNT") {
					//金额
					if(!isNaN(itemAmount) && !isNaN(itemUnitPrice)) {
						itemCost = accMul(itemAmount, itemUnitPrice);
						document.getElementById("cost_" + index).value = parseScale(itemCost, 2);
					}
				} else if(priceType == "LENGTH") {
					var itemLength = document.getElementById("length_" + index).value;
					var itemWidth = document.getElementById("width_" + index).value;
					var itemSquareNum = document.getElementById("square_num_" + index).value;
					var lengType = "MAX";
					//长度
					if(!isNaN(itemLength) && !isNaN(itemWidth) && !isNaN(itemAmount)) {
						if(lengType == "WIDTH") {
							itemSquareNum = accMul(itemLength, itemAmount);
						} else if(lengType == "TALL") {
							itemSquareNum = accMul(itemWidth, itemAmount);
						} else {
							if(Number(itemLength) > Number(itemWidth)) {
								itemSquareNum = accMul(itemLength, itemAmount);
							} else {
								itemSquareNum = accMul(itemWidth, itemAmount);
							}
						}
						itemSquareNum = parseScale(itemSquareNum, 3);
						document.getElementById("square_num_" + index).value = itemSquareNum;
					}
					//规格
					if(id == "length_" + index || id == "width_" + index) {
						if(!isNaN(itemLength) && !isNaN(itemWidth)) {
							var lt = document.getElementById("leng_type_" + index).value.toLowerCase();;
							var speStr = "";
							if(itemLength - 0 != 0) {
								speStr = itemLength + lt;
							}
							if(itemWidth - 0 != 0) {
								if(speStr != "") {
									speStr = speStr + " x ";
								}
								speStr = speStr + itemWidth + lt;
							}
							document.getElementById("specification_" + index).value = speStr;
						}
					}
					//金额
					if(!isNaN(itemSquareNum) && !isNaN(itemUnitPrice)) {
						itemCost = accMul(itemSquareNum, itemUnitPrice);
						document.getElementById("cost_" + index).value = parseScale(itemCost, 2);
					}
				}
				doCount();
			}

			function doCount() {
				var itemNum = document.getElementById("item_num").value - 0;
				var costTotal = 0;
				var itemCost;
				var itemAmount;

				var priceType;
				var lengItemNum = 0,
					areaItemNum = 0,
					amouItemNum = 0;
				var lengMTotal = 0,
					lengCmTotal = 0,
					areaTotal = 0,
					amountTotal = 0;
				var lengthCost = 0,
					areaCost = 0,
					amountCost = 0;

				for(var i = 0; i < itemNum; i++) {
					if(document.getElementById("status_" + i).value != "DELETE") {
						itemCost = document.getElementById("cost_" + i).value;
						if(!isNaN(itemCost)) {
							costTotal = addMul(costTotal, itemCost);
						}

						priceType = document.getElementById("price_type_" + i).value;
						if(priceType == "AMOUNT") {
							if(!isNaN(itemCost)) {
								amountCost = addMul(amountCost, itemCost);
							}
							itemAmount = document.getElementById("amount_" + i).value;
							if(!isNaN(itemAmount)) {
								amountTotal = addMul(amountTotal, itemAmount);
							}
							amouItemNum = amouItemNum + 1;
						} else if(priceType == "AREA") {
							if(!isNaN(itemCost)) {
								areaCost = addMul(areaCost, itemCost);
							}
							var itemArea = document.getElementById("square_num_" + i).value;
							if(!isNaN(itemArea)) {
								areaTotal = addMul(areaTotal, itemArea);
							}
							areaItemNum = areaItemNum + 1;
						} else if(priceType == "LENGTH") {
							if(!isNaN(itemCost)) {
								lengthCost = addMul(lengthCost, itemCost);
							}
							var itemLength = document.getElementById("square_num_" + i).value;
							if(!isNaN(itemLength)) {
								if(document.getElementById("leng_type_" + i).value == "M") {
									lengMTotal = addMul(lengMTotal, itemLength);
								} else {
									lengCmTotal = addMul(lengCmTotal, itemLength);
								}
							}
							lengItemNum = lengItemNum + 1;
						}
					}
				}
				var favCost = document.getElementById("favCostStr").value;
				if(!isNaN(favCost)) {
					costTotal = abateMul(costTotal, favCost);
				}
				document.getElementById("cooperBill.cost").value = costTotal;
				if(document.getElementById("areaTotalSpan") != null) {
					document.getElementById("areaTotalSpan").innerHTML = "记录：" + areaItemNum + "条&nbsp;面积：" + areaTotal + "平方米&nbsp;金额：" + areaCost + "元";
				}
				if(document.getElementById("amountTotalSpan") != null) {
					document.getElementById("amountTotalSpan").innerHTML = "记录：" + amouItemNum + "条&nbsp;数量：" + amountTotal + "&nbsp;金额：" + amountCost + "元";
				}
				if(document.getElementById("lengTotalSpan") != null) {
					document.getElementById("lengTotalSpan").innerHTML = "记录：" + lengItemNum + "条&nbsp;长度：" + lengMTotal + "米&nbsp;" + lengCmTotal + "公分&nbsp;金额：" + lengthCost + "元";
				}
			}

			function selectManager() {
				var url = "/base/StafferMainForSelect.ihtm";
				ShowIframe("选择员工", url, 800, 500, "selectManagerCallBack()");
			}

			function selectManagerCallBack() {
				if(popRetVal != null) {
					var arr = popRetVal.split(";");
					document.getElementById("cooperBill.managerId").value = arr[0];
					document.getElementById("cooperBill.managerName").value = arr[1];
				}
			}

			function doPrint(id) {
				showWin(900, 600, "/cooper/CooperBillPrint.ihtm?id=" + id);
			}

			function selectContact() {
				var estId = document.getElementById("cooperBill.cooperatorId").value;
				var url = "/base/ContactListForSelect.ihtm?est_id=" + estId;
				ShowIframe("选择联系人", url, 500, 320, "selectContactCallBack()");
			}

			function selectContactCallBack() {
				if(popRetVal != null) {
					document.getElementById("cooperBill.linkman").value = popRetVal[0];
					document.getElementById("cooperBill.phone").value = popRetVal[1];
				}
			}

			function selectCooperator() {
				var url = "/base/EstablishmentListForSelect.ihtm?type=COOPERATOR&ts_id=2&order_type=BUS_TIME";
				ShowIframe("选择外协商", url, 900, 500, "selectCooperatorCallBack()");
			}

			function selectCooperatorCallBack() {
				if(popRetVal != null) {
					document.getElementById("LoadProcess").style.top = getTopPos(document.getElementById("cooperatorName")) + 50 + "px";
					document.getElementById("LoadProcess").style.left = getleftPos(document.getElementById("cooperatorName")) + 100 + "px";
					$("#LoadProcess").show();

					document.getElementById("cooperBill.cooperatorId").value = popRetVal[0];
					document.getElementById("cooperatorName").value = popRetVal[1];
					document.getElementById("estMngId").value = popRetVal[2];
					if(popRetVal[2] != "0") {
						document.getElementById("cooperBill.managerId").value = popRetVal[2];
						document.getElementById("cooperBill.managerName").value = popRetVal[3];
					}
					document.getElementById("cooperBill.address").value = popRetVal[6];
					document.getElementById("cooperBill.linkman").value = popRetVal[7];
					document.getElementById("cooperBill.phone").value = popRetVal[8];

					loadCoopPrice(popRetVal[0]);
				}
			}

			function loadCoopPrice(estId) {
				var itemNum = document.getElementById("item_num").value - 0;
				var hasItem = false;
				for(var i = 0; i < itemNum; i++) {
					if(document.getElementById("status_" + i).value != "DELETE") {
						hasItem = true;
						break;
					}
				}
				if(hasItem) {
					$.post("/base/GetEstPricList.ihtm", {
						est_type: "COOPERATOR",
						price_type: "EST",
						est_id: estId
					}, function(data, status) {
						parseCoopPriceData(data, status);
					});
				} else {
					document.getElementById("LoadProcess").style.visibility = "hidden";
					setFocus("cooperBill.linkman");
				}
			}

			function parseCoopPriceData(data, status) {
				if(status == "success") {
					var obj = $.parseJSON(data);
					if(obj.status == "ERROR") {
						$("#LoadProcess").hide();
						ShowAlert('提示框', obj.errMsg, 200, 100);
					} else {
						var itemNum = $("#item_num").val() - 0;
						$.each(obj.items, function(index, item) {
							for(var i = 0; i < itemNum; i++) {
								if($("#status_" + i).val() != "DELETE") {
									if(item.mtId == $("#make_type_id_" + i).val() && item.proName == $("#pro_name_" + i).val()) {
										$("#unit_price_" + i).val(item.pric);
										checkItemChange(i);
									}
								}
							}
						});
						$("#LoadProcess").hide();
					}
				} else {
					$("#LoadProcess").hide();
					ShowAlert('提示框', '系统错误：' + status, 200, 100);
				}
			}

			function changeTimeSelect(obj, targetName) {
				document.getElementById(targetName).value = obj.value;
			}

			function doClear(idObjId, nameObjId, index) {
				if(idObjId != null && idObjId != '') {
					document.getElementById(idObjId).value = "0";
				}
				if(nameObjId != null && nameObjId != '') {
					document.getElementById(nameObjId).value = "";
				}
				if(index != null) { //奶奶的，js里面0跟''比较是相等的，所以这里不能用index!=''，否则index为0时有问题
					checkItemChange(index);
				}
			}

			function doInit() {

				if(document.addEventListener) {
					var fdArea = document.getElementById("filedrag_area");
					if(fdArea) {
						fdArea.addEventListener("dragover", function(e) {
							fileDragHover(e, fdArea.id, "AREA")
						}, false);
						fdArea.addEventListener("dragleave", function(e) {
							fileDragHover(e, fdArea.id, "AREA")
						}, false);
						fdArea.addEventListener("drop", function(e) {
							fileSelectHandler(e, fdArea.id, "AREA")
						}, false);
					}

					var fdLeng = document.getElementById("filedrag_leng");
					if(fdLeng) {
						fdLeng.addEventListener("dragover", function(e) {
							fileDragHover(e, fdLeng.id, "LENGTH")
						}, false);
						fdLeng.addEventListener("dragleave", function(e) {
							fileDragHover(e, fdLeng.id, "LENGTH")
						}, false);
						fdLeng.addEventListener("drop", function(e) {
							fileSelectHandler(e, fdLeng.id, "LENGTH")
						}, false);
					}

					var fdAmou = document.getElementById("filedrag_amou");
					if(fdAmou) {
						fdAmou.addEventListener("dragover", function(e) {
							fileDragHover(e, fdAmou.id, "AMOUNT")
						}, false);
						fdAmou.addEventListener("dragleave", function(e) {
							fileDragHover(e, fdAmou.id, "AMOUNT")
						}, false);
						fdAmou.addEventListener("drop", function(e) {
							fileSelectHandler(e, fdAmou.id, "AMOUNT")
						}, false);
					}
				}

				setFocus("cooperBill.linkman");
				showFormErrorMsg();
				resizePopwin();
			}
			var dragFiles, dragProp, dragFlags;

			function fileDragHover(e, divId, type) {
				e.stopPropagation(); //停止事件的传播,阻止它被分派到其他 Document 节点
				e.preventDefault(); //通知浏览器不要执行与事件关联的默认动作(否则浏览器会显示文件)
				var elem = e.target;
				while(elem.id != divId) {
					elem = elem.parentNode;
				}
				elem.className = (e.type == "dragover" ? "DragOver" : "");
			}

			function fileSelectHandler(e, divId, type) {
				fileDragHover(e, divId, type);
				dragFiles = e.dataTransfer.files;
				var cooperatorId = document.getElementById("cooperBill.cooperatorId").value;
				ShowIframeNoScroll("设置图片的制作属性", "/business/BusinessDragProp.ihtm?est_type=COOPERATOR&est_id=" + cooperatorId, 400, 320, "fileSelectHandlerExt('" + type + "')");
			}

			function fileSelectHandlerExt(type) {
				if(popRetVal) {
					dragProp = popRetVal;
					dragFlags = new Array();
					for(var i = 0; i < dragFiles.length; i++) {
						dragFlags[i] = "N";
					}
					var posiObj;
					if(type == "AMOUNT") {
						posiObj = "filedrag_amou";
					} else if(type == "AREA") {
						posiObj = "filedrag_area";
					} else {
						posiObj = "filedrag_leng";
					}
					document.getElementById("LoadProcess").style.top = getTopPos(posiObj) + 50 + "px";
					document.getElementById("LoadProcess").style.left = getleftPos(posiObj) + 100 + "px";
					$("#LoadProcess").show();
					setTimeout("checkDragStatus()", 1000);

					for(var i = 0; i < dragFiles.length; i++) {
						checkFile(dragFiles[i], type, i);
					}
				}
			}

			function checkDragStatus() {
				var comp = true;
				for(var i = 0; i < dragFlags.length; i++) {
					if(dragFlags[i] == "N") {
						comp = false;
						break;
					}
				}
				if(comp) {
					$("#LoadProcess").hide();
				} else {
					setTimeout("checkDragStatus()", 1000);
				}
			}

			function checkFile(file, type, index) {
				var cont = file.name;
				var lastInde = cont.lastIndexOf(".");
				if(lastInde != -1) {
					cont = cont.substring(0, lastInde);
				}
				var reader = new FileReader();
				reader.onload = function(e) {
					var json = EkImgParser.parse(e.target.result); //ArrayBuffer
					addItemByDragFile(type, cont, json.width, json.height, index);
				};
				reader.readAsArrayBuffer(file);
			}

			function addItemByDragFile(type, cont, widt, heig, index) {
				var defVals = new Array();
				defVals[0] = dragProp[0];
				defVals[1] = dragProp[1];
				defVals[2] = dragProp[2];
				defVals[3] = dragProp[3];
				defVals[7] = cont;
				defVals[8] = dragProp[4];
				defVals[9] = dragProp[6];
				defVals[10] = dragProp[5];
				defVals[11] = dragProp[7];
				defVals[12] = "0";
				defVals[13] = "0";
				defVals[14] = "0";
				defVals[15] = "";
				if(type == "AREA") {
					var entAreaType = "M";
					defVals[6] = "";
					if(widt != "") {
						if(entAreaType == "M") {
							widt = parseScale(widt / 100, 3);
							heig = parseScale(heig / 100, 3);
							defVals[6] = widt + "m x " + heig + "m";
						} else { //MM
							widt = parseScale(accMul(widt, 10), 3);
							heig = parseScale(accMul(heig, 10), 3);
							defVals[6] = widt + "mm x " + heig + "mm";
						}
					}
					defVals[4] = widt;
					defVals[5] = heig;
					defVals[16] = entAreaType;
					doAreaItemAdd(defVals);
				} else if(type == "AMOUNT") {
					defVals[4] = "0";
					defVals[5] = "0";
					defVals[6] = "";
					if(widt != "") {
						defVals[6] = parseScale(widt, 3) + "cm x " + parseScale(heig, 3) + "cm";
					}
					defVals[16] = "";
					doAmountItemAdd(defVals);
				} else if(type == "LENGTH") {
					var entLengType = "M";
					defVals[6] = "";
					if(widt != "") {
						if(entLengType == "M") {
							widt = parseScale(widt / 100, 3);
							heig = parseScale(heig / 100, 3);
							defVals[6] = widt + "m x " + heig + "m高";
						} else { //CM
							widt = parseScale(widt, 3);
							heig = parseScale(heig, 3);
							defVals[6] = widt + "cm x " + heig + "cm高";
						}
					}
					defVals[4] = widt;
					defVals[5] = heig;
					defVals[16] = entLengType;
					doLengthItemAdd(defVals);
				}
				dragFlags[index] = "Y";
			}

			function addLinkman() {
				var estId = document.getElementById("cooperBill.cooperatorId").value;
				var linkman = document.getElementById("cooperBill.linkman").value.trim();
				var phone = document.getElementById("cooperBill.phone").value.trim();
				if(estId == "" || estId == "0") {
					ShowAlert('提示框', '请先选择外协商！', 200, 100);
				} else if(linkman == "" || phone == "") {
					ShowAlert('提示框', '联系人姓名与电话不能空！', 200, 100);
				} else {
					var url = "/base/EstContAdd.ihtm?est_id=" + estId + "&linkman=" + encodeURIComponent(linkman) + "&phone=" + encodeURIComponent(phone);
					var xmlHttp = createXMLHttpRequest();
					xmlHttp.open("GET", url, true);
					xmlHttp.onreadystatechange = function() {
						if(xmlHttp.readyState == 4) {
							if(xmlHttp.status == 200) {
								var resTxt = xmlHttp.responseText;
								if(resTxt == "CONT_EXIST") {
									ShowAlert('提示框', '联系人已经存在！', 200, 100);
								} else {
									ShowAlert('提示框', '添加成功！', 200, 100);
								}
							}
						}
					};
					xmlHttp.send(null);
				}
			}
			//AccessoryList.ihtm使用
			function refreshAccWin() {
				if(popRetVal != null) {
					document.getElementById("accessoryFrm").contentWindow.refreshWin();
				}
			}

			function doDelAcc(id) {
				if(popRetVal != null) {
					document.getElementById("accessoryFrm").contentWindow.doDelAct(id);
				}
			}
		</script>

	</head>

	<body onload="doInit();">
		<div>
			<form class="layui-form" name="frm" method="post">
				<div class="Container">
					<div class="Contnet Paper">
						<!-- 是否可以编辑附件 -->
						<!-- 保存按钮是否可点击 -->
						<!-- 编码框是否可点击 -->
						<!-- 编码框颜色 -->
						<!-- 材料框是否可点击 -->
						<!-- 材料框颜色 -->
						<!-- 除编码材料框外的控件的disabled状态 -->
						<!-- 除编码材料框外的控件的readonly状态 -->
						<!-- 除编码材料框外的控件的颜色 -->
						<!-- 是否可以编辑日期 -->
						<!-- 是否查看别人单据 -->

						<!-- 提示信息 -->

						<script language="javascript">
							var formErrorIndex = 0;
							var formErrorMsg = "";
							var formErrorObjId = "";

							function setFormErrorMsg(msg, index, objId) {
								if(formErrorIndex == 0 || formErrorIndex > index) {
									if(msg != null && msg != "") {
										formErrorIndex = index;
										formErrorMsg = msg;
										formErrorObjId = objId;
									}
								}
							}

							function showFormErrorMsg() {
								if(formErrorIndex != 0) {
									document.getElementById("errorMsgTr").style.display = "";
									document.getElementById("errorMsgDiv").innerHTML = formErrorMsg;
									if(formErrorObjId != null && formErrorObjId != "") {
										document.getElementById(formErrorObjId).focus();
									}
								}
							}

							function goNextInput(objId) {
								var obj = null;
								if(objId != null && objId != '') {
									obj = document.getElementById(objId);
								}
								if(window.event.keyCode == 13) {
									if(obj != null) {
										obj.focus();
									} else if(window.doSave) {
										doSave();
									}
								}
							}
						</script>

						<!--单 标题-->
						<div class="BillHeading">
							<div class="layui-row">
								<div class="layui-col-sm4">
									<div class="CorpLogo"><img src="../images/BIAO  SHI  HUI.png"></div>
								</div>
								<div class="layui-col-sm4">
									<h1>新增外协单</h1>
								</div>
								<div class="layui-col-sm4 tr" style="">
									<div class="layui-form-item" style="display: inline-block;margin-top: 10px;margin-bottom: 8px;">
										<!--<label class="layui-form-label"><span class="MustInput">*</span>编号：</label>-->
										<div class="layui-input-inline">
											&nbsp;
											<!--<input class="layui-input" readonly placeholder="" type="text" maxlength="30" onkeyup="goNextInput('cooperDateStr');" id="cooperBill.billCode" name="cooperBill.billCode" value="">-->
										</div>
									</div>
									<div class="layui-form-item" style="display: inline-block;">
										<label class="layui-form-label"><span class="MustInput">*</span>编号：</label>
										<div class="layui-input-inline">
											<input class="layui-input" readonly placeholder="" type="text" maxlength="30" onkeyup="goNextInput('cooperDateStr');" id="cooperBill.billCode" name="cooperBill.billCode" value="">
										</div>
									</div>
									<div class="layui-form-item" style="display: inline-block;">
										<label class="layui-form-label"><span class="MustInput">*</span>外协日期：</label>
										<div class="layui-input-inline" style="width: 85px;">
											<input class="layui-input" placeholder="" type="text" maxlength="15" onkeyup="goNextInput('cooperBill.linkman');" id="cooperDateStr" name="cooperDateStr" value="2017-11-21">
										</div>
										<div class="layui-input-inline" style="width: 55px;">
											<select id="cooperDateHourSelect" class="ddlDateHour" onchange="changeTimeSelect(this,'cooperDateHour');">
												<option value="00">00</option>
												<option value="01">01</option>
												<option value="02">02</option>
												<option value="03" selected="">03</option>
												<option value="04">04</option>
												<option value="05">05</option>
												<option value="06">06</option>
												<option value="07">07</option>
												<option value="08">08</option>
												<option value="09">09</option>
												<option value="10">10</option>
												<option value="11">11</option>
												<option value="12">12</option>
												<option value="13">13</option>
												<option value="14">14</option>
												<option value="15">15</option>
												<option value="16">16</option>
												<option value="17">17</option>
												<option value="18">18</option>
												<option value="19">19</option>
												<option value="20">20</option>
												<option value="21">21</option>
												<option value="22">22</option>
												<option value="23">23</option>
											</select>
										</div>
										<div class="layui-input-inline" style="width: 55px;">
											<select id="cooperDateMinuteSelect" class="ddlDateMinute" onchange="changeTimeSelect(this,'cooperDateMinute');">
												<option value="00">00</option>
												<option value="01" selected="">01</option>
												<option value="02">02</option>
												<option value="03">03</option>
												<option value="04">04</option>
												<option value="05">05</option>
												<option value="06">06</option>
												<option value="07">07</option>
												<option value="08">08</option>
												<option value="09">09</option>
												<option value="10">10</option>
												<option value="11">11</option>
												<option value="12">12</option>
												<option value="13">13</option>
												<option value="14">14</option>
												<option value="15">15</option>
												<option value="16">16</option>
												<option value="17">17</option>
												<option value="18">18</option>
												<option value="19">19</option>
												<option value="20">20</option>
												<option value="21">21</option>
												<option value="22">22</option>
												<option value="23">23</option>
												<option value="24">24</option>
												<option value="25">25</option>
												<option value="26">26</option>
												<option value="27">27</option>
												<option value="28">28</option>
												<option value="29">29</option>
												<option value="30">30</option>
												<option value="31">31</option>
												<option value="32">32</option>
												<option value="33">33</option>
												<option value="34">34</option>
												<option value="35">35</option>
												<option value="36">36</option>
												<option value="37">37</option>
												<option value="38">38</option>
												<option value="39">39</option>
												<option value="40">40</option>
												<option value="41">41</option>
												<option value="42">42</option>
												<option value="43">43</option>
												<option value="44">44</option>
												<option value="45">45</option>
												<option value="46">46</option>
												<option value="47">47</option>
												<option value="48">48</option>
												<option value="49">49</option>
												<option value="50">50</option>
												<option value="51">51</option>
												<option value="52">52</option>
												<option value="53">53</option>
												<option value="54">54</option>
												<option value="55">55</option>
												<option value="56">56</option>
												<option value="57">57</option>
												<option value="58">58</option>
												<option value="59">59</option>
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="blank12"></div>
						<!-- 单 头信息 -->
						<div class="layui-row">
							<div class="layui-col-sm3">
								<div class="layui-form-item">
									<label class="layui-form-label" style="width: 70px;"><span class="MustInput">*</span>外协单位：</label>
									<div class="layui-input-inline" style="width: 100px;">
										<input class="layui-input" readonly placeholder="" type="text" id="cooperatorName" name="cooperatorName" value="">
									</div>
									<div class="layui-form-mid">
										<a href="">选择</a>
									</div>
									<div class="layui-form-mid layui-word-aux">大客户</div>
								</div>
							</div>
							<div class="layui-col-sm3 tc">
								<div class="layui-form-item" style="display: inline-block;">
									<label class="layui-form-label" style="width: 70px;">联系人：</label>
									<div class="layui-input-inline" style="width: 140px;">
										<input class="layui-input" placeholder="" type="text" maxlength="15" onkeyup="goNextInput('cooperBill.phone');" id="cooperBill.linkman" name="cooperBill.linkman" value="">
									</div>
									<div class="layui-form-mid">
										<a href="">选择</a>
									</div>
								</div>
							</div>
							<div class="layui-col-sm3 tc">
								<div class="layui-form-item" style="display: inline-block;">
									<label class="layui-form-label" style="width: 70px;">电话：</label>
									<div class="layui-input-inline" style="width: 140px;">
										<input class="layui-input" placeholder="" type="text" maxlength="40" onkeyup="goNextInput('cooperBill.address');" id="cooperBill.phone" name="cooperBill.phone" value="">
									</div>
									<div class="layui-form-mid">
										<a href="">添加</a>
									</div>
								</div>
							</div>
							<div class="layui-col-sm3 tr">
								<div class="layui-form-item" style="display: inline-block;">
									<label class="layui-form-label" style="width: 70px;">合同号：</label>
									<div class="layui-input-inline" style="width: 140px;">
										<input class="layui-input" placeholder="" type="text" maxlength="50" onkeyup="goNextInput('businessBill.setupRequire');" id="businessBill.contractCode" name="businessBill.contractCode" value="">
									</div>
								</div>
							</div>
						</div>

						<!-- 明细 -->
						<input type="hidden" id="item_num" name="item_num" value="0">

						<div id="filedrag_area">
							<table id="BillDetails" class="BillDetails" width="100%" cellspacing="0" cellpadding="0">
								<tbody id="areaItemRowTbl">
									<tr>
										<th width="8%">项目类型</th>
										<th width="19%">内容</th>
										<th width="8%">材质</th>
										<th width="10%">宽x高</th>
										<th width="7%">规格</th>
										<th width="11%">制作要求</th>
										<th width="5%">数量</th>
										<th width="6%">平方数</th>
										<th width="5%">元/平</th>
										<th width="5%">金额</th>
										<th width="11%">来源</th>
										<th width="4%">操作</th>
									</tr>

								</tbody>
							</table>
							<div class="table-bot">
								<span id="areaTotalSpan" style="float:right;PADDING-RIGHT:10px;color:#aaa">
	        		记录：0条&nbsp;
					面积：0平方米&nbsp;
					金额：0元
				</span>

								<a id="linkObjArea" href="javascript:doBbItemSelect('AREA','linkObjArea');">选择业务单外协项目</a>

								<a href="javascript:doAreaItemAdd();">增加平方计价项目</a>
								<span id="hiSpanArea"><a href="javascript:doItemSelect('AREA');">选择最近交易价格</a></span>
								<a href="javascript:doCbItemSelect('AREA','STA');">选择标准价格</a>
								<span id="epSpanArea"><a href="javascript:doCbItemSelect('AREA','EST');">选择外协商价格</a></span>
								<span title="自动读取图片尺寸、文件名，自动识别项目类型（喷绘、室内写真、户外写真、裱板、数码彩旗、弱溶剂、写真背板、旗帜、写真、UV打印），填写外协单">可直接拖动图片到这里 <img src="/images/arrow_up.png" height="14px"></span>

							</div>
						</div>
						<br>

						<div id="filedrag_leng">
							<table id="BillDetails" class="BillDetails" width="100%" cellspacing="0" cellpadding="0">
								<tbody id="lengthItemRowTbl">
									<tr>
										<th width="8%">项目类型</th>
										<th width="19%">内容</th>
										<th width="8%">材质</th>
										<th width="10%">宽x高</th>
										<th width="7%">规格</th>
										<th width="11%">制作要求</th>
										<th width="5%">数量</th>
										<th width="6%">总长度</th>
										<th width="5%">单价</th>
										<th width="5%">金额</th>
										<th width="11%">来源</th>
										<th width="4%">操作</th>
									</tr>

								</tbody>
							</table>
							<div class="table-bot">
								<span id="lengTotalSpan" style="float:right;PADDING-RIGHT:10px;color:#aaa">
	        		记录：0条&nbsp;
					长度：0米&nbsp;0公分&nbsp;
					金额：0元
				</span>

								<a id="linkObjLeng" href="javascript:doBbItemSelect('LENGTH','linkObjLeng');">选择业务单外协项目</a>

								<a href="javascript:doLengthItemAdd();">增加长度计价项目</a>
								<span id="hiSpanLength"><a href="javascript:doItemSelect('LENGTH');">选择最近交易价格</a></span>
								<a href="javascript:doCbItemSelect('LENGTH','STA');">选择标准价格</a>
								<span id="epSpanLength"><a href="javascript:doCbItemSelect('LENGTH','EST');">选择外协商价格</a></span>
								<span title="自动读取图片尺寸、文件名、自动识别项目类型（写真条幅、激光条幅、条幅、横幅），填写外协单">可直接拖动图片到这里 <img src="/images/arrow_up.png" height="14px"></span>

							</div>
						</div>
						<br>

						<div id="filedrag_amou">
							<table id="BillDetails" class="BillDetails" width="100%" cellspacing="0" cellpadding="0">
								<tbody id="amountItemRowTbl">
									<tr>
										<th width="8%">项目类型</th>
										<th width="19%">内容</th>
										<th width="8%">材质</th>
										<th width="10%">规格</th>
										<th width="15%">制作要求</th>
										<th width="8%">单位</th>
										<th width="6%">数量</th>
										<th width="5%">单价</th>
										<th width="5%">金额</th>
										<th width="11%">来源</th>
										<th width="4%">操作</th>
									</tr>

								</tbody>
							</table>
							<div class="table-bot">
								<span id="amountTotalSpan" style="float:right;PADDING-RIGHT:10px;color:#aaa">
			 		记录：0条&nbsp;
					数量：0&nbsp;
					金额：0元
				</span>

								<a id="linkObjAmou" href="javascript:doBbItemSelect('AMOUNT','linkObjAmou');">选择业务单外协项目</a>

								<a href="javascript:doAmountItemAdd();">增加成品计价项目</a>
								<span id="hiSpanAmount"><a href="javascript:doItemSelect('AMOUNT');">选择最近交易价格</a></span>
								<a href="javascript:doCbItemSelect('AMOUNT','STA');">选择标准价格</a>
								<span id="epSpanAmount"><a href="javascript:doCbItemSelect('AMOUNT','EST');">选择外协商价格</a></span>
								<span title="自动读取图片尺寸、文件名，填写外协单">可直接拖动图片到这里 <img src="/images/arrow_up.png" height="14px"></span>

							</div>
						</div>
						<br>
						<hr />


						<!-- 附加信息 -->
						<div class="layui-row">
							<div class="layui-col-sm4">
								<div class="layui-form-item">
									<label class="layui-form-label">部门：</label>
									<div class="layui-input-inline">
																					<select id="cooperBill.departmentId" name="cooperBill.departmentId" class="ddlInfo1">
												<option value="0">==请选择==</option>

												<option value="1">易凯管理员</option>
												<option value="50">&nbsp;|--1</option>
												<option value="13">总经办</option>
												<option value="22">&nbsp;|--财务</option>
												<option value="14">新异店</option>
												<option value="15">&nbsp;|--客服</option>
												<option value="23">&nbsp;|--设计</option>
												<option value="24">&nbsp;|--业务</option>
												<option value="16">业务来源</option>
												<option value="17">标识加工车间</option>
												<option value="21">合作伙伴</option>
												<option value="32" selected="">标识汇运营部</option>
												<option value="33">财务部</option>
												<option value="35">新异标识标牌有限公司</option>
												<option value="36">&nbsp;|--物流部</option>
												<option value="41">&nbsp;|--销售部</option>
												<option value="42">&nbsp;|--业务部</option>
												<option value="43">&nbsp;|--设计部</option>
												<option value="44">&nbsp;|--安装部</option>
												<option value="45">&nbsp;|--外协(东厂)</option>
												<option value="46">&nbsp;|--财务部</option>
												<option value="48">&nbsp;|--门市部</option>
												<option value="49">&nbsp;|--加工车间</option>
												<option value="37">&nbsp;&nbsp;|--标牌部</option>
												<option value="38">&nbsp;&nbsp;|--标识部</option>
												<option value="39">&nbsp;&nbsp;|--型材加工部</option>
												<option value="40">&nbsp;&nbsp;|--字加工部</option>
											</select>
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">业务员：</label>
									<div class="layui-input-inline" style="width: 140px;">
										<input class="layui-input" readonly placeholder="" type="text" id="cooperBill.managerName" name="cooperBill.managerName" value="">
									</div>
									<div class="layui-form-mid">
										<a href="" onclick="selectManager();">选择</a>
									</div>
									<div class="layui-form-mid">
										<a href="" onclick="doClear('cooperBill.managerId','cooperBill.managerName');">清空</a>
									</div>
								</div>
							</div>
							<div class="layui-col-sm4">
								<div class="layui-form-item">
									<label class="layui-form-label">交货要求：</label>
									<div class="layui-input-inline">
										<input class="layui-input" placeholder="" type="text" maxlength="50" onkeyup="goNextInput('cooperBill.setupRequire');" id="cooperBill.gatherRequire" name="cooperBill.gatherRequire" value="">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">安装要求：</label>
									<div class="layui-input-inline">
										<input class="layui-input" placeholder="" type="text" maxlength="50" onkeyup="goNextInput('cooperBill.content');" id="cooperBill.setupRequire" name="cooperBill.setupRequire" value="">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label"><span class="MustInput">*</span>交货日期：</label>
									<div class="layui-input-inline" style="width: 85px;">
										<input class="layui-input" placeholder="" type="text" maxlength="15" id="gatherDateStr" name="gatherDateStr" value="">
									</div>
									<div class="layui-input-inline" style="width: 55px;">
																					<select id="gatherDateHourSelect" class="ddlDateHour" onchange="changeTimeSelect(this,'gatherDateHour');">
												<option value="00">00</option>
												<option value="01">01</option>
												<option value="02">02</option>
												<option value="03" selected="">03</option>
												<option value="04">04</option>
												<option value="05">05</option>
												<option value="06">06</option>
												<option value="07">07</option>
												<option value="08">08</option>
												<option value="09">09</option>
												<option value="10">10</option>
												<option value="11">11</option>
												<option value="12">12</option>
												<option value="13">13</option>
												<option value="14">14</option>
												<option value="15">15</option>
												<option value="16">16</option>
												<option value="17">17</option>
												<option value="18">18</option>
												<option value="19">19</option>
												<option value="20">20</option>
												<option value="21">21</option>
												<option value="22">22</option>
												<option value="23">23</option>
											</select>

									</div>
									<div class="layui-input-inline" style="width: 55px;">
																					<select id="gatherDateMinuteSelect" class="ddlDateMinute" onchange="changeTimeSelect(this,'gatherDateMinute');">
												<option value="00">00</option>
												<option value="01" selected="">01</option>
												<option value="02">02</option>
												<option value="03">03</option>
												<option value="04">04</option>
												<option value="05">05</option>
												<option value="06">06</option>
												<option value="07">07</option>
												<option value="08">08</option>
												<option value="09">09</option>
												<option value="10">10</option>
												<option value="11">11</option>
												<option value="12">12</option>
												<option value="13">13</option>
												<option value="14">14</option>
												<option value="15">15</option>
												<option value="16">16</option>
												<option value="17">17</option>
												<option value="18">18</option>
												<option value="19">19</option>
												<option value="20">20</option>
												<option value="21">21</option>
												<option value="22">22</option>
												<option value="23">23</option>
												<option value="24">24</option>
												<option value="25">25</option>
												<option value="26">26</option>
												<option value="27">27</option>
												<option value="28">28</option>
												<option value="29">29</option>
												<option value="30">30</option>
												<option value="31">31</option>
												<option value="32">32</option>
												<option value="33">33</option>
												<option value="34">34</option>
												<option value="35">35</option>
												<option value="36">36</option>
												<option value="37">37</option>
												<option value="38">38</option>
												<option value="39">39</option>
												<option value="40">40</option>
												<option value="41">41</option>
												<option value="42">42</option>
												<option value="43">43</option>
												<option value="44">44</option>
												<option value="45">45</option>
												<option value="46">46</option>
												<option value="47">47</option>
												<option value="48">48</option>
												<option value="49">49</option>
												<option value="50">50</option>
												<option value="51">51</option>
												<option value="52">52</option>
												<option value="53">53</option>
												<option value="54">54</option>
												<option value="55">55</option>
												<option value="56">56</option>
												<option value="57">57</option>
												<option value="58">58</option>
												<option value="59">59</option>
											</select>

									</div>
								</div>
							</div>
							<div class="layui-col-sm4">
								<div class="layui-form-item">
									<label class="layui-form-label">优惠金额：</label>
									<div class="layui-input-inline">
										<input class="layui-input" placeholder="" type="text" maxlength="10" name="favCostStr" id="favCostStr" value="">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">折后金额：</label>
									<div class="layui-input-inline">
										<input class="layui-input" readonly placeholder="" type="text" maxlength="10" name="cooperBill.cost" id="cooperBill.cost" value="">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">预付款：</label>
									<div class="layui-input-inline">
										<input class="layui-input" placeholder="" type="text" maxlength="10" id="imprestStr" name="imprestStr" value="">
									</div>
								</div>
							</div>
						</div>
						<div class="layui-row">
							<div class="layui-col-sm8">
								<hr />
							</div>
							<div class="layui-col-sm4">
								<div class="layui-form-item">
									<label class="layui-form-label">付款方式：</label>
									<div class="layui-input-inline">
																					<select id="cooperBill.payModeId" name="cooperBill.payModeId" class="ddlInfo3">

												<option value="1">现结</option>

												<option value="2">月结</option>

												<option value="3">季结</option>

												<option value="4">公户转帐</option>

												<option value="5">支付宝转帐</option>

												<option value="6">银行转帐</option>

												<option value="7">物流代收</option>

												<option value="8">微信转帐</option>

												<option value="9">取货付款</option>

											</select>

									</div>
								</div>
							</div>
						</div>
						<div class="layui-row">
							<div class="layui-col-sm4">
								<div class="layui-form-item">
									<label class="layui-form-label">摘要：</label>
									<div class="layui-input-inline">
										<input class="layui-input" placeholder="" type="text" maxlength="200" onkeyup="goNextInput('cooperBill.mark');" id="cooperBill.content" name="cooperBill.content" value="">
									</div>
								</div>
							</div>
							<div class="layui-col-sm4">
								<div class="layui-form-item">
									<label class="layui-form-label">备注：</label>
									<div class="layui-input-inline">
										<input class="layui-input" placeholder="" type="text" maxlength="200" maxlength="50" id="cooperBill.mark" name="cooperBill.mark" value="">
									</div>
								</div>
							</div>
							<div class="layui-col-sm4">
								<div class="layui-form-item">
									<label class="layui-form-label">付款账户：</label>
									<div class="layui-input-inline">
										<select id="cooperBill.bankAccountId" name="cooperBill.bankAccountId" class="ddlInfo3_long">

											</select>
									</div>
								</div>
							</div>
						</div>

						<!-- 附件 -->
						<br>
						<table class="BillAttachments" cellspacing="0" cellpadding="0">
							<tbody>
								<tr>
									<td>
										<iframe name="accessoryFrm" id="accessoryFrm" scrolling="no" border="0" frameborder="0" height="0" width="100%" src="../business/AccessoryList.html" style="height: 90px;"></iframe>
									</td>
								</tr>
							</tbody>
						</table>

						<div class="BillNotes">
							<span>开单人：杨海波 2017-11-21 03:01</span>
							<span>审核人：</span>
							<span>修改人：</span>
							<span>单据帐套：网络公司</span>

							<script language="javascript">
								setFormErrorMsg('', 1);
							</script>

						</div>
					</div>

					<!-- 底栏按钮 -->
					<div class="Footer">
						<div id="buttonDiv">
							<input type="button" class="buttom-a" value=" 保 存 " onclick="doSave('');">
							<input type="hidden" name="continue_flag" id="continue_flag" value="">

							<input type="button" class="buttom-a" value=" 保存并新增 " onclick="doSave('NEW');">
							<input type="button" class="buttom-a" value=" 保存并关闭 " onclick="doSave('CLOSE');">
							<input type="button" class="buttom-a" value=" 保存并打印 " onclick="doSave('PRINT');">

							<input type="button" class="buttom-a" value=" 取 消 " onclick="doCancel();">
							<input type="hidden" id="sychronizeValue" name="sychronizeValue" value="0">
							<input type="hidden" id="tmpCode" name="tmpCode" value="22_1511204474128">
							<input type="hidden" id="cooperDateHour" name="cooperDateHour" value="03">
							<input type="hidden" id="cooperDateMinute" name="cooperDateMinute" value="01">
							<input type="hidden" id="gatherDateHour" name="gatherDateHour" value="03">
							<input type="hidden" id="gatherDateMinute" name="gatherDateMinute" value="01">

							<input type="hidden" name="examine" id="examine" value="0">

							<input type="hidden" id="estMngId" name="estMngId" value="61">
						</div>
						<div id="waitDiv" style="display:none">
							<span>请稍候...</span>
						</div>
					</div>

				</div>
			</form>
		</div>

		<div id="LoadProcess" style="position:absolute; left:50%;top:50%; width:200px; height:100px; margin-top:-50px;margin-left:-100px;z-index:1; border:solid #000 5px;background-color:White;display:none">
			<table border="0" align="center" style="height:100%;">
				<tbody>
					<tr>
						<td style="valign:middle">
							<img src="/images/loading.gif"> 请稍候...
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<script src="../js/jquery-3.0.0.min.js"></script>
		<script src="../layui/layui.all.js"></script>
	</body>

</html>